﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ImageList控件制作图片查看器
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public int PicIndex = 0;

        private void Form1_Load(object sender, EventArgs e)
        {
            this.pictureBox1.Image=this.imageList1.Images[0];
            this.checkButton();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.PicIndex--;
            this.pictureBox1.Image = this.imageList1.Images[PicIndex];
            this.checkButton();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.PicIndex++;
            this.pictureBox1.Image = this.imageList1.Images[PicIndex];
            this.checkButton();
        }

        private void checkButton()
        {
            if (PicIndex== 0) { 
                this.button1.Enabled = false;
            }
            else
            {
                this.button1.Enabled = true;
            }
            if (this.imageList1.Images.Count - 1 == PicIndex)
            {
                this.button2.Enabled = false;
            }
            else {
                this.button2.Enabled = true;
            }
        }

        private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.ShowDialog();
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
